package com.wxmit.module.system.domain.server;

import cn.hutool.core.util.NumberUtil;

/**
 * CPU相关信息
 * 
 * @author ruoyi
 */
public class Cpu
{
    /**
     * CPU名称
     */
    private String cpuName;

    /**
     * CPU物理个数
     */
    private int physicalPackageCount;
    /**
     * CPU物理核心数
     */
    private int physicalProcessorCount;
    /**
     * CPU逻辑核心数
     */
    private int logicalProcessorCount;

    /**
     * CPU总的使用率
     */
    private double total;

    /**
     * CPU系统使用率
     */
    private double sys;

    /**
     * CPU用户使用率
     */
    private double used;

    /**
     * CPU当前等待率
     */
    private double wait;

    /**
     * CPU当前空闲率
     */
    private double free;

    public String getCpuName() {
        return cpuName;
    }

    public void setCpuName(String cpuName) {
        this.cpuName = cpuName;
    }

    public int getPhysicalPackageCount() {
        return physicalPackageCount;
    }

    public void setPhysicalPackageCount(int physicalPackageCount) {
        this.physicalPackageCount = physicalPackageCount;
    }

    public int getPhysicalProcessorCount() {
        return physicalProcessorCount;
    }

    public void setPhysicalProcessorCount(int physicalProcessorCount) {
        this.physicalProcessorCount = physicalProcessorCount;
    }

    public int getLogicalProcessorCount() {
        return logicalProcessorCount;
    }

    public void setLogicalProcessorCount(int logicalProcessorCount) {
        this.logicalProcessorCount = logicalProcessorCount;
    }

    public double getTotal()
    {
        return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue();
    }

    public void setTotal(double total)
    {
        this.total = total;
    }

    public double getSys()
    {
        return round(sys , total);
    }



    public void setSys(double sys)
    {
        this.sys = sys;
    }

    public double getUsed()
    {
        return round(used , total);
    }

    public void setUsed(double used)
    {
        this.used = used;
    }

    public double getWait()
    {
        return round(wait , total);
    }

    public void setWait(double wait)
    {
        this.wait = wait;
    }

    public double getFree()
    {
        return round(free , total);
    }

    public void setFree(double free)
    {
        this.free = free;
    }

    private double round(double mul, double total) {
        return NumberUtil.round(NumberUtil.mul(mul / total, 100), 2).doubleValue();
    }
}
